package cn.tedu.serializable;

import java.io.*;

/**
 * @author ：Dsi
 * @date ：2021/11/17 10:35
 * Describe ：该类用于测试序列化和反序列化
 */
public class TestSerializable {
    public static void main(String[] args) throws Throwable {
        new File("D:\\save1117").mkdir();
        new File("D:\\save1117\\1.txt").createNewFile();
        //m1();
        m2();
    }

    private static void m2() throws Throwable {
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("D:\\save1117\\1.txt"));
        ois.readObject();
        ois.close();

    }

    private static void m1() throws Throwable {
        Student a=new Student("海绵宝宝",45,"大海",'男');
        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("D:\\save1117\\1.txt"));
        oos.writeObject(a);
        oos.close();
    }
}
